import 'package:daoyi_ui_admin_getx/generated/locales.g.dart';
import 'package:flutter/material.dart';

import 'package:get/get.dart';

import 'tabs_controller.dart';

class TabsView extends GetView<TabsController> {
  final Rx<String> current = (Get.parameters['current']??'').obs;

  TabsView({super.key});

  @override
  Widget build(BuildContext context) {
    if ('' != current.value) {
      controller.changePage(int.parse(current.value));
    }
    return Scaffold(
      body: Obx(
        () => controller.tabViewList[controller.currentIndex.value],
      ),
      bottomNavigationBar: Obx(
        () => BottomNavigationBar(
          items: <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: const Icon(Icons.home_outlined),
              activeIcon: const Icon(Icons.home),
              label: LocaleKeys.tabs_home.tr,
            ),
            BottomNavigationBarItem(
              icon: const Icon(Icons.window_outlined),
              activeIcon: const Icon(Icons.window_rounded),
              label: LocaleKeys.tabs_navigator.tr,
            ),
            BottomNavigationBarItem(
              icon: const Icon(Icons.explore_outlined),
              activeIcon: const Icon(Icons.explore),
              label: LocaleKeys.tabs_discovery.tr,
            ),
            BottomNavigationBarItem(
              icon: const Icon(Icons.person_outline),
              activeIcon: const Icon(Icons.person),
              label: LocaleKeys.tabs_mine.tr,
            ),
          ],
          currentIndex: controller.currentIndex.value,
          onTap: (index) {
            current.value = index.toString();
            controller.changePage(index);
          },
        ),
      ),
    );
  }
}
